package org.example.infrastructure.repository.orm.database;

import lombok.RequiredArgsConstructor;
import org.example.domain.repository.UserAccountRepository;
import org.example.domain.system.model.UserAccount;
import org.example.infrastructure.persistence.orm.UserAccountMapper;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Repository;

import java.util.Optional;

/**
 * @author
 */
@Repository
@RequiredArgsConstructor
public class MyBatisUserAccountRepository implements UserAccountRepository {
    private final UserAccountMapper userAccountMapper;

    @Override
    public Optional<UserAccount> getUserAccountByUserName(@NonNull String userName) {
        UserAccount userAccount = userAccountMapper.getUserAccountByUserName(userName);
        return Optional.ofNullable(userAccount);

    }

    @Override
    public int registerUser(UserAccount userAccount) {
        return userAccountMapper.registerUser(userAccount);
    }

    @Override
    public int updateUser(UserAccount userAccount) {
        return userAccountMapper.updateUser(userAccount);
    }
}
